package com.example.demo.dao;

import com.example.demo.entity.SysUser;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

public interface SysUserMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table sys_user
     *
     * @mbg.generated
     */
    @Delete({
        "delete from sys_user",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table sys_user
     *
     * @mbg.generated
     */
    @Insert({
        "insert into sys_user (username, birthday, ",
        "sex, `password`, phone, ",
        "`status`, open_id, city, ",
        "avatar_url, last_login_date, ",
        "registration_date, del_status)",
        "values (#{username,jdbcType=VARCHAR}, #{birthday,jdbcType=DATE}, ",
        "#{sex,jdbcType=TINYINT}, #{password,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, ",
        "#{status,jdbcType=BIT}, #{openId,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, ",
        "#{avatarUrl,jdbcType=VARCHAR}, #{lastLoginDate,jdbcType=TIMESTAMP}, ",
        "#{registrationDate,jdbcType=TIMESTAMP}, #{delStatus,jdbcType=BIT})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(SysUser record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table sys_user
     *
     * @mbg.generated
     */
    @Select({
        "select",
        "id, username, birthday, sex, `password`, phone, `status`, open_id, city, avatar_url, ",
        "last_login_date, registration_date, del_status",
        "from sys_user",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="username", property="username", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
        @Result(column="sex", property="sex", jdbcType=JdbcType.TINYINT),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.BIT),
        @Result(column="open_id", property="openId", jdbcType=JdbcType.VARCHAR),
        @Result(column="city", property="city", jdbcType=JdbcType.VARCHAR),
        @Result(column="avatar_url", property="avatarUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="last_login_date", property="lastLoginDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="registration_date", property="registrationDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_status", property="delStatus", jdbcType=JdbcType.BIT)
    })
    SysUser selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table sys_user
     *
     * @mbg.generated
     */
    @Select({
        "select",
        "id, username, birthday, sex, `password`, phone, `status`, open_id, city, avatar_url, ",
        "last_login_date, registration_date, del_status",
        "from sys_user"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="username", property="username", jdbcType=JdbcType.VARCHAR),
        @Result(column="birthday", property="birthday", jdbcType=JdbcType.DATE),
        @Result(column="sex", property="sex", jdbcType=JdbcType.TINYINT),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="phone", property="phone", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.BIT),
        @Result(column="open_id", property="openId", jdbcType=JdbcType.VARCHAR),
        @Result(column="city", property="city", jdbcType=JdbcType.VARCHAR),
        @Result(column="avatar_url", property="avatarUrl", jdbcType=JdbcType.VARCHAR),
        @Result(column="last_login_date", property="lastLoginDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="registration_date", property="registrationDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="del_status", property="delStatus", jdbcType=JdbcType.BIT)
    })
    List<SysUser> selectAll();

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table sys_user
     *
     * @mbg.generated
     */
    @Update({
        "update sys_user",
        "set username = #{username,jdbcType=VARCHAR},",
          "birthday = #{birthday,jdbcType=DATE},",
          "sex = #{sex,jdbcType=TINYINT},",
          "`password` = #{password,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "`status` = #{status,jdbcType=BIT},",
          "open_id = #{openId,jdbcType=VARCHAR},",
          "city = #{city,jdbcType=VARCHAR},",
          "avatar_url = #{avatarUrl,jdbcType=VARCHAR},",
          "last_login_date = #{lastLoginDate,jdbcType=TIMESTAMP},",
          "registration_date = #{registrationDate,jdbcType=TIMESTAMP},",
          "del_status = #{delStatus,jdbcType=BIT}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(SysUser record);
}